<?php
class Pageley_Domain_Validator_Boolean extends Pageley_Domain_Validator_Abstract {
	
	private $notABooleanMessage = "error.validation.notABoolean";
	
	public function validate($value, $propertyName, $object) {
		$errors = new Pageley_Util_ArrayMap();
		if($value !== null && $value !== "") {
            $notABoolean = $this->rejectIfFalse($value === true || $value === false, $this->notABooleanMessage, array("{field." . $propertyName . "}", $value));
    		if($notABoolean) {
    			$errors->put($propertyName, $notABoolean);
    		}
        }
		return $errors;
	}
	
	public function setNotABooleanMessage($notABooleanMessage) {
		$this->notABooleanMessage = $notABooleanMessage;
	}
}